// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

CharacterBase{
    id: _root
    width: 5
    height: 10
    color: "#00aaaaaa"

    property real speed: 240        // pixel/sec
    property real duration: 2000    // msec
    property real toX: 0

    Image{
        anchors.fill: parent
        fillMode: Image.PreserveAspectCrop
        source: "./images/wal_bullet.png"
    }


    function init(obj){
        toX = obj._toX;
        var len = Math.sqrt(Math.pow(Math.abs(toX - x),2)
                            + Math.pow(Math.abs(fieldHeight + height), 2));
        duration = 1000 * len / speed + 500;
        _anim.start();
    }

    function move(){
    }

    ParallelAnimation {
        id: _anim
        running: false
        NumberAnimation {
            target: _root
            property: "x"
            to: toX
            duration: _root.duration
        }
        NumberAnimation {
            target: _root
            property: "y"
            to: fieldHeight + height + y
            duration: _root.duration
        }
    }

    function resumeAnimation(){
        _anim.restart();
    }
    function pauseAnimation(){
        _anim.pause();
    }
}
